package snake.demo.obj;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import snake.demo.common.GameWin;
import snake.demo.util.GameUtils;

import java.awt.*;
import java.util.Random;

/**
 * @author A
 * @version 1.0
 * @description: TODO
 * @date 2022/10/25 14:59
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class FoodObj extends GameObj {

    Random random =new Random();
    public FoodObj(Image img, int x, int y, GameWin frame) {
        super(img, x, y, frame);
    }

    @Override
    public void paintSelf(Graphics g) {
        super.paintSelf(g);
    }

    //获取食物
    public FoodObj getFood(){
        return new FoodObj(GameUtils.foodImg,random.nextInt(20)*30,(random.nextInt(19)+1)*30,frame);
    }
}
